/**
 * 
 */
package org.apache.hadoop.io;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * @author tim
 */
public class Text implements WritableComparable {
	protected String s;
	public Text(String s) {
		this.s = s;
	}

	public void readFields(DataInputStream in) throws IOException {
		s=in.readUTF();
	}

	public void write(DataOutputStream out) throws IOException {
		out.writeUTF(s);
	}
	
	@Override
	public String toString() {
		return s;
	}
	
	@Override
	public boolean equals(Object o) {
		if (o instanceof Text
				&& (s!=null)) {
			return s.equals(((Text)o).toString());
		} else if (o instanceof Text 
				&& s==null && ((Text)o).toString()==null) {
			return true;
		}
		return false;
	}

	public int compareTo(Object o) {
		return s.compareTo(o.toString());
	}
}
